package com.mqz.seckill.controller;

import com.mqz.seckill.rabbitmq.MQProducer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class RabbitMQHandler {
    @Resource
    private MQProducer mqProducer;

    @RequestMapping("/mq")
    @ResponseBody
    public void mq() {
        mqProducer.send("hello,rabbit!");
    }

    @RequestMapping("/fanout")
    @ResponseBody
    public void fanout() {
        mqProducer.sendToFanout("hello,rabbit!");
    }

    @RequestMapping("/d1")
    @ResponseBody
    public void direct01() {
        mqProducer.sendToDirect01("hello,d1!");
    }

    @RequestMapping("/d2")
    @ResponseBody
    public void direct02() {
        mqProducer.sendToDirect02("hello,d2!");
    }

    @RequestMapping("/t1")
    @ResponseBody
    public void topic01() {
        mqProducer.sendToTopic01("hello,t1!");
    }

    @RequestMapping("/t2")
    @ResponseBody
    public void topic02() {
        mqProducer.sendToTopic02("hello,t2!");
    }

}
